<?php 
  function query_futtatas($query)
  { 
    $query = trim($query);
    $dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    mysql_select_db(DB_NAME);
    
    mysql_query("SET NAMES UTF8",$dbc);
    $data = mysql_query($query, $dbc);
    
    $tipus = "";
    if (strpos($query,"INSERT") === 0)
    {
      $tipus = "insert";
    }
    if (strpos($query,"SELECT") === 0)
    {
      $tipus = "select";
    }
    
    $eredmeny = true;
    switch ($tipus)
    {
      case "insert":
        $eredmeny = mysql_insert_id();
        break;
      case "select":
        $eredmeny = array();
        $i = 0;
        while($row = mysql_fetch_array($data))
        {
          $eredmeny[$i++] = $row;
        }
        break;
    }
    
    mysql_close($dbc);
    return $eredmeny;
  }
 
?>